{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# PyTorch：神经网络模块nn"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "计算图和autograd是十分强大的工具，可以定义复杂的操作并自动求导；然而对于大规模的网络，autograd太过于底层。\n",
    "\n",
    "在构建神经网络时，我们经常考虑将计算安排成**层**，其中一些具有**可学习的参数**，它们将在学习过程中进行优化。\n",
    "\n",
    "TensorFlow里，有类似[Keras](https://github.com/fchollet/keras)，[TensorFlow-Slim](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim)和[TFLearn](http://tflearn.org/)这种封装了底层计算图的高度抽象的接口，这使得构建网络十分方便。 \n",
    "\n",
    "在PyTorch中，包`nn`完成了同样的功能。`nn`包中定义一组大致等价于层的**模块**。一个模块接受输入的tesnor，计算输出的tensor，而且还保存了一些内部状态比如需要学习的tensor的参数等。`nn`包中也定义了一组损失函数（loss functions），用来训练神经网络。 \n",
    "\n",
    "这个例子中，我们用`nn`包实现两层的网络："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0 589.2650756835938\n",
      "1 544.6754150390625\n",
      "2 505.7870788574219\n",
      "3 471.72601318359375\n",
      "4 441.301513671875\n",
      "5 413.9375\n",
      "6 389.0218505859375\n",
      "7 366.3975830078125\n",
      "8 345.60821533203125\n",
      "9 326.4293212890625\n",
      "10 308.5284118652344\n",
      "11 291.85858154296875\n",
      "12 276.22216796875\n",
      "13 261.5279235839844\n",
      "14 247.6606903076172\n",
      "15 234.5232391357422\n",
      "16 222.09951782226562\n",
      "17 210.32373046875\n",
      "18 199.12088012695312\n",
      "19 188.49383544921875\n",
      "20 178.3958740234375\n",
      "21 168.78872680664062\n",
      "22 159.64785766601562\n",
      "23 150.9722442626953\n",
      "24 142.72666931152344\n",
      "25 134.9013671875\n",
      "26 127.47538757324219\n",
      "27 120.43806457519531\n",
      "28 113.7598876953125\n",
      "29 107.41643524169922\n",
      "30 101.40911102294922\n",
      "31 95.72021484375\n",
      "32 90.34722137451172\n",
      "33 85.25762939453125\n",
      "34 80.44406127929688\n",
      "35 75.89909362792969\n",
      "36 71.5885238647461\n",
      "37 67.51824951171875\n",
      "38 63.66319274902344\n",
      "39 60.03507995605469\n",
      "40 56.62186813354492\n",
      "41 53.39593505859375\n",
      "42 50.35042953491211\n",
      "43 47.486915588378906\n",
      "44 44.79405975341797\n",
      "45 42.25392150878906\n",
      "46 39.87065124511719\n",
      "47 37.629173278808594\n",
      "48 35.51384735107422\n",
      "49 33.525028228759766\n",
      "50 31.6563720703125\n",
      "51 29.895206451416016\n",
      "52 28.237743377685547\n",
      "53 26.679447174072266\n",
      "54 25.213275909423828\n",
      "55 23.836620330810547\n",
      "56 22.543235778808594\n",
      "57 21.325597763061523\n",
      "58 20.1801700592041\n",
      "59 19.103317260742188\n",
      "60 18.089052200317383\n",
      "61 17.133567810058594\n",
      "62 16.234066009521484\n",
      "63 15.386627197265625\n",
      "64 14.587982177734375\n",
      "65 13.834731101989746\n",
      "66 13.125785827636719\n",
      "67 12.457884788513184\n",
      "68 11.826875686645508\n",
      "69 11.230712890625\n",
      "70 10.667795181274414\n",
      "71 10.135236740112305\n",
      "72 9.631307601928711\n",
      "73 9.154982566833496\n",
      "74 8.704204559326172\n",
      "75 8.277530670166016\n",
      "76 7.873587608337402\n",
      "77 7.491838455200195\n",
      "78 7.129607677459717\n",
      "79 6.78635835647583\n",
      "80 6.461336135864258\n",
      "81 6.153408050537109\n",
      "82 5.861268043518066\n",
      "83 5.584557056427002\n",
      "84 5.321964740753174\n",
      "85 5.07240104675293\n",
      "86 4.835513591766357\n",
      "87 4.610856056213379\n",
      "88 4.397435665130615\n",
      "89 4.194691181182861\n",
      "90 4.001925468444824\n",
      "91 3.81868839263916\n",
      "92 3.6446142196655273\n",
      "93 3.47904109954834\n",
      "94 3.3217225074768066\n",
      "95 3.1719770431518555\n",
      "96 3.029611587524414\n",
      "97 2.894228219985962\n",
      "98 2.7653965950012207\n",
      "99 2.6427361965179443\n",
      "100 2.525949478149414\n",
      "101 2.414565086364746\n",
      "102 2.308497190475464\n",
      "103 2.207502603530884\n",
      "104 2.111158847808838\n",
      "105 2.019408702850342\n",
      "106 1.9319703578948975\n",
      "107 1.848684310913086\n",
      "108 1.7691950798034668\n",
      "109 1.6933468580245972\n",
      "110 1.6209681034088135\n",
      "111 1.5520789623260498\n",
      "112 1.4864051342010498\n",
      "113 1.423648476600647\n",
      "114 1.3636921644210815\n",
      "115 1.3064261674880981\n",
      "116 1.2517080307006836\n",
      "117 1.1994084119796753\n",
      "118 1.149410605430603\n",
      "119 1.1016528606414795\n",
      "120 1.0560499429702759\n",
      "121 1.012433648109436\n",
      "122 0.9707397818565369\n",
      "123 0.930884063243866\n",
      "124 0.8927690386772156\n",
      "125 0.8563339114189148\n",
      "126 0.821448028087616\n",
      "127 0.7881356477737427\n",
      "128 0.7561967372894287\n",
      "129 0.725608766078949\n",
      "130 0.6963278651237488\n",
      "131 0.6683068871498108\n",
      "132 0.6414618492126465\n",
      "133 0.6157541871070862\n",
      "134 0.5911353826522827\n",
      "135 0.5675606727600098\n",
      "136 0.5449562668800354\n",
      "137 0.5233063697814941\n",
      "138 0.5025754570960999\n",
      "139 0.4827023148536682\n",
      "140 0.46365582942962646\n",
      "141 0.4454081058502197\n",
      "142 0.4278929829597473\n",
      "143 0.41110363602638245\n",
      "144 0.39501407742500305\n",
      "145 0.37957581877708435\n",
      "146 0.364755243062973\n",
      "147 0.3505546748638153\n",
      "148 0.336942195892334\n",
      "149 0.3238750994205475\n",
      "150 0.31133031845092773\n",
      "151 0.2992890179157257\n",
      "152 0.2877313792705536\n",
      "153 0.2766498327255249\n",
      "154 0.2660122513771057\n",
      "155 0.2558050751686096\n",
      "156 0.24600672721862793\n",
      "157 0.23659555613994598\n",
      "158 0.2275712490081787\n",
      "159 0.2188987135887146\n",
      "160 0.21057121455669403\n",
      "161 0.20257648825645447\n",
      "162 0.19489893317222595\n",
      "163 0.18752335011959076\n",
      "164 0.18043339252471924\n",
      "165 0.17362317442893982\n",
      "166 0.16707971692085266\n",
      "167 0.16079720854759216\n",
      "168 0.15476353466510773\n",
      "169 0.14896118640899658\n",
      "170 0.14338503777980804\n",
      "171 0.13802826404571533\n",
      "172 0.1328791081905365\n",
      "173 0.12792791426181793\n",
      "174 0.12316667288541794\n",
      "175 0.11859013885259628\n",
      "176 0.1141943633556366\n",
      "177 0.10996606945991516\n",
      "178 0.10589936375617981\n",
      "179 0.10198712348937988\n",
      "180 0.09822741150856018\n",
      "181 0.09461433440446854\n",
      "182 0.09113840758800507\n",
      "183 0.08780279010534286\n",
      "184 0.08463462442159653\n",
      "185 0.08158569782972336\n",
      "186 0.07865258306264877\n",
      "187 0.07582925260066986\n",
      "188 0.07311338186264038\n",
      "189 0.0704970508813858\n",
      "190 0.0679764524102211\n",
      "191 0.06555131077766418\n",
      "192 0.06321631371974945\n",
      "193 0.06097036600112915\n",
      "194 0.058806177228689194\n",
      "195 0.05672170966863632\n",
      "196 0.05471383407711983\n",
      "197 0.052780549973249435\n",
      "198 0.050916992127895355\n",
      "199 0.049122728407382965\n",
      "200 0.04739588126540184\n",
      "201 0.04572989419102669\n",
      "202 0.04412494972348213\n",
      "203 0.04257865622639656\n",
      "204 0.04108843952417374\n",
      "205 0.0396525077521801\n",
      "206 0.03826797381043434\n",
      "207 0.03693386912345886\n",
      "208 0.03564858436584473\n",
      "209 0.03440902754664421\n",
      "210 0.03321396932005882\n",
      "211 0.032062236219644547\n",
      "212 0.030952468514442444\n",
      "213 0.02988312765955925\n",
      "214 0.028851712122559547\n",
      "215 0.027856608852744102\n",
      "216 0.026897992938756943\n",
      "217 0.02597554586827755\n",
      "218 0.025085700675845146\n",
      "219 0.02422797493636608\n",
      "220 0.02340114116668701\n",
      "221 0.022603431716561317\n",
      "222 0.02183375135064125\n",
      "223 0.02109057828783989\n",
      "224 0.02037387154996395\n",
      "225 0.019682373851537704\n",
      "226 0.019015731289982796\n",
      "227 0.018372157588601112\n",
      "228 0.017750967293977737\n",
      "229 0.017151637002825737\n",
      "230 0.016573622822761536\n",
      "231 0.016015712171792984\n",
      "232 0.015477191656827927\n",
      "233 0.014957495965063572\n",
      "234 0.014455932192504406\n",
      "235 0.013971728272736073\n",
      "236 0.013504364527761936\n",
      "237 0.013053128495812416\n",
      "238 0.01261757779866457\n",
      "239 0.012196911498904228\n",
      "240 0.011790959164500237\n",
      "241 0.01139912474900484\n",
      "242 0.011020827107131481\n",
      "243 0.010655298829078674\n",
      "244 0.01030218880623579\n",
      "245 0.00996121484786272\n",
      "246 0.009632078930735588\n",
      "247 0.009314286522567272\n",
      "248 0.009007245302200317\n",
      "249 0.0087104681879282\n",
      "250 0.00842385645955801\n",
      "251 0.008147009648382664\n",
      "252 0.007879577577114105\n",
      "253 0.007621243130415678\n",
      "254 0.0073717557825148106\n",
      "255 0.00713056605309248\n",
      "256 0.006897585466504097\n",
      "257 0.006672565825283527\n",
      "258 0.006455026101320982\n",
      "259 0.006244943477213383\n",
      "260 0.006041914224624634\n",
      "261 0.005845705978572369\n",
      "262 0.0056561981327831745\n",
      "263 0.005472893361002207\n",
      "264 0.005295631475746632\n",
      "265 0.005124474875628948\n",
      "266 0.00495897326618433\n",
      "267 0.004798986949026585\n",
      "268 0.004644341301172972\n",
      "269 0.004494728986173868\n",
      "270 0.0043501704931259155\n",
      "271 0.004210419021546841\n",
      "272 0.004075315315276384\n",
      "273 0.003944655414670706\n",
      "274 0.0038184141740202904\n",
      "275 0.0036962588783353567\n",
      "276 0.003578155068680644\n",
      "277 0.0034640321973711252\n",
      "278 0.0033536143600940704\n",
      "279 0.0032468184363096952\n",
      "280 0.0031434213742613792\n",
      "281 0.003043483942747116\n",
      "282 0.00294690509326756\n",
      "283 0.002853506011888385\n",
      "284 0.0027631770353764296\n",
      "285 0.0026757651939988136\n",
      "286 0.00259118783287704\n",
      "287 0.002509346231818199\n",
      "288 0.0024301910307258368\n",
      "289 0.0023536416701972485\n",
      "290 0.0022795721888542175\n",
      "291 0.0022079204209148884\n",
      "292 0.002138556679710746\n",
      "293 0.0020714462734758854\n",
      "294 0.0020065063145011663\n",
      "295 0.0019436792936176062\n",
      "296 0.0018828734755516052\n",
      "297 0.0018240036442875862\n",
      "298 0.001767061068676412\n",
      "299 0.001711950171738863\n",
      "300 0.0016586401034146547\n",
      "301 0.001607053796760738\n",
      "302 0.0015570539981126785\n",
      "303 0.0015086844796314836\n",
      "304 0.00146188260987401\n",
      "305 0.001416554907336831\n",
      "306 0.0013726839097216725\n",
      "307 0.0013302190927788615\n",
      "308 0.0012891186634078622\n",
      "309 0.0012493099784478545\n",
      "310 0.0012107688235118985\n",
      "311 0.0011734546860679984\n",
      "312 0.0011373304296284914\n",
      "313 0.0011023657862097025\n",
      "314 0.0010684937005862594\n",
      "315 0.001035677152685821\n",
      "316 0.001003909157589078\n",
      "317 0.0009731324971653521\n",
      "318 0.0009433442028239369\n",
      "319 0.0009145050426013768\n",
      "320 0.0008865764830261469\n",
      "321 0.0008595001418143511\n",
      "322 0.0008332814904861152\n",
      "323 0.0008078940445557237\n",
      "324 0.0007832897244952619\n",
      "325 0.0007594464696012437\n",
      "326 0.000736366375349462\n",
      "327 0.000714014982804656\n",
      "328 0.0006923449109308422\n",
      "329 0.0006713620387017727\n",
      "330 0.0006510239909403026\n",
      "331 0.0006313305930234492\n",
      "332 0.0006122437189333141\n",
      "333 0.0005937661626376212\n",
      "334 0.0005758527549915016\n",
      "335 0.000558509083930403\n",
      "336 0.0005416828207671642\n",
      "337 0.0005253903800621629\n",
      "338 0.0005095931701362133\n",
      "339 0.0004942804807797074\n",
      "340 0.00047944209654815495\n",
      "341 0.0004650693736039102\n",
      "342 0.0004511357401497662\n",
      "343 0.0004376285651233047\n",
      "344 0.0004245346935931593\n",
      "345 0.00041183628491126\n",
      "346 0.0003995338920503855\n",
      "347 0.0003876128466799855\n",
      "348 0.00037605545367114246\n",
      "349 0.00036486575845628977\n",
      "350 0.00035399943590164185\n",
      "351 0.0003434685349930078\n",
      "352 0.00033325969707220793\n",
      "353 0.0003233706811442971\n",
      "354 0.00031377573031932116\n",
      "355 0.00030447286553680897\n",
      "356 0.0002954525698442012\n",
      "357 0.00028671426116488874\n",
      "358 0.00027823325945064425\n",
      "359 0.0002700125623960048\n",
      "360 0.0002620430605020374\n",
      "361 0.0002543101436458528\n",
      "362 0.00024680778733454645\n",
      "363 0.0002395355113549158\n",
      "364 0.00023249248624779284\n",
      "365 0.00022565068502444774\n",
      "366 0.0002190182713093236\n",
      "367 0.00021259105415083468\n",
      "368 0.0002063635183731094\n",
      "369 0.00020032166503369808\n",
      "370 0.00019446243823040277\n",
      "371 0.00018877905677072704\n",
      "372 0.0001832620910136029\n",
      "373 0.00017791370919439942\n",
      "374 0.00017272205150220543\n",
      "375 0.00016769212379585952\n",
      "376 0.0001628027093829587\n",
      "377 0.00015806738520041108\n",
      "378 0.00015346756845247\n",
      "379 0.00014901184476912022\n",
      "380 0.00014468334848061204\n",
      "381 0.00014048196317162365\n",
      "382 0.0001364119234494865\n",
      "383 0.00013246008893474936\n",
      "384 0.00012862132280133665\n",
      "385 0.00012490259541664273\n",
      "386 0.00012129169044783339\n",
      "387 0.0001177869999082759\n",
      "388 0.00011438730143709108\n",
      "389 0.00011108363105449826\n",
      "390 0.0001078796194633469\n",
      "391 0.00010476822353666648\n",
      "392 0.00010175161878578365\n",
      "393 9.882387530524284e-05\n",
      "394 9.598234464647248e-05\n",
      "395 9.322045661974698e-05\n",
      "396 9.054376278072596e-05\n",
      "397 8.794393215794116e-05\n",
      "398 8.542563591618091e-05\n",
      "399 8.297536260215566e-05\n",
      "400 8.059561514528468e-05\n",
      "401 7.828899833839387e-05\n",
      "402 7.604701386298984e-05\n",
      "403 7.387461664620787e-05\n",
      "404 7.176276267273352e-05\n",
      "405 6.971237598918378e-05\n",
      "406 6.772228516638279e-05\n",
      "407 6.579118053195998e-05\n",
      "408 6.391644274117425e-05\n",
      "409 6.20962237007916e-05\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "410 6.032829696778208e-05\n",
      "411 5.8611640270100906e-05\n",
      "412 5.694355786545202e-05\n",
      "413 5.532684372155927e-05\n",
      "414 5.3756135457661e-05\n",
      "415 5.223140760790557e-05\n",
      "416 5.074905129731633e-05\n",
      "417 4.931008879793808e-05\n",
      "418 4.791326500708237e-05\n",
      "419 4.65558550786227e-05\n",
      "420 4.5239936298457906e-05\n",
      "421 4.395968426251784e-05\n",
      "422 4.2715393647085875e-05\n",
      "423 4.150742825004272e-05\n",
      "424 4.033457298646681e-05\n",
      "425 3.919770824722946e-05\n",
      "426 3.809118061326444e-05\n",
      "427 3.70176239812281e-05\n",
      "428 3.597621980588883e-05\n",
      "429 3.4962748031830415e-05\n",
      "430 3.3979951695073396e-05\n",
      "431 3.3025477023329586e-05\n",
      "432 3.209626447642222e-05\n",
      "433 3.119434404652566e-05\n",
      "434 3.031898449989967e-05\n",
      "435 2.9467932108673267e-05\n",
      "436 2.864056841644924e-05\n",
      "437 2.7837490051751956e-05\n",
      "438 2.7058515115641057e-05\n",
      "439 2.6300187528249808e-05\n",
      "440 2.5563938834238797e-05\n",
      "441 2.484721517248545e-05\n",
      "442 2.415318158455193e-05\n",
      "443 2.3476990463677794e-05\n",
      "444 2.2822221581009217e-05\n",
      "445 2.218485860794317e-05\n",
      "446 2.1566036593867466e-05\n",
      "447 2.0964427676517516e-05\n",
      "448 2.0379064153530635e-05\n",
      "449 1.9813061953755096e-05\n",
      "450 1.9259379769209772e-05\n",
      "451 1.872286338766571e-05\n",
      "452 1.820338366087526e-05\n",
      "453 1.7696465874905698e-05\n",
      "454 1.720470390864648e-05\n",
      "455 1.672781399975065e-05\n",
      "456 1.6261712517007254e-05\n",
      "457 1.5809866454219446e-05\n",
      "458 1.537306343379896e-05\n",
      "459 1.4946240298741031e-05\n",
      "460 1.453168715670472e-05\n",
      "461 1.4129093869996723e-05\n",
      "462 1.3738162124354858e-05\n",
      "463 1.3356743693293538e-05\n",
      "464 1.2987334230274428e-05\n",
      "465 1.2629738193936646e-05\n",
      "466 1.2279551810934208e-05\n",
      "467 1.1940196600335184e-05\n",
      "468 1.1610611181822605e-05\n",
      "469 1.1290210750303231e-05\n",
      "470 1.0979003491229378e-05\n",
      "471 1.0675942576199304e-05\n",
      "472 1.0380784260632936e-05\n",
      "473 1.0095608558913227e-05\n",
      "474 9.817258614930324e-06\n",
      "475 9.548385605739895e-06\n",
      "476 9.285186933993828e-06\n",
      "477 9.029713510244619e-06\n",
      "478 8.781080396147445e-06\n",
      "479 8.540151611668989e-06\n",
      "480 8.304906259581912e-06\n",
      "481 8.077397069428116e-06\n",
      "482 7.855684089008719e-06\n",
      "483 7.640044714207761e-06\n",
      "484 7.42979000278865e-06\n",
      "485 7.226785328384722e-06\n",
      "486 7.028359505056869e-06\n",
      "487 6.835637123003835e-06\n",
      "488 6.6488264565123245e-06\n",
      "489 6.466371360147605e-06\n",
      "490 6.289420070970664e-06\n",
      "491 6.117904376878869e-06\n",
      "492 5.950383638264611e-06\n",
      "493 5.787953796243528e-06\n",
      "494 5.629515271721175e-06\n",
      "495 5.476061687659239e-06\n",
      "496 5.326558039087104e-06\n",
      "497 5.181246251595439e-06\n",
      "498 5.039612915425096e-06\n",
      "499 4.902348791802069e-06\n"
     ]
    }
   ],
   "source": [
    "# 可运行代码见本文件夹中的 two_layer_net_nn.py\n",
    "import torch\n",
    "\n",
    "device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')\n",
    "\n",
    "# N是批大小；D是输入维度\n",
    "# H是隐藏层维度；D_out是输出维度\n",
    "N, D_in, H, D_out = 64, 1000, 100, 10\n",
    "\n",
    "# 产生输入和输出随机张量\n",
    "x = torch.randn(N, D_in, device=device)\n",
    "y = torch.randn(N, D_out, device=device)\n",
    "\n",
    "\n",
    "# 使用nn包将我们的模型定义为一系列的层。\n",
    "# nn.Sequential是包含其他模块的模块，并按顺序应用这些模块来产生其输出。\n",
    "# 每个线性模块使用线性函数从输入计算输出，并保存其内部的权重和偏差张量。\n",
    "# 在构造模型之后，我们使用.to()方法将其移动到所需的设备。\n",
    "model = torch.nn.Sequential(\n",
    "            torch.nn.Linear(D_in, H),\n",
    "            torch.nn.ReLU(),\n",
    "            torch.nn.Linear(H, D_out),\n",
    "        ).to(device)\n",
    "\n",
    "\n",
    "# nn包还包含常用的损失函数的定义；\n",
    "# 在这种情况下，我们将使用平均平方误差(MSE)作为我们的损失函数。\n",
    "# 设置reduction='sum'，表示我们计算的是平方误差的“和”，而不是平均值;\n",
    "# 这是为了与前面我们手工计算损失的例子保持一致，\n",
    "# 但是在实践中，通过设置reduction='elementwise_mean'来使用均方误差作为损失更为常见。\n",
    "loss_fn = torch.nn.MSELoss(reduction='sum')\n",
    "\n",
    "learning_rate = 1e-4\n",
    "for t in range(500):\n",
    "\n",
    "    # 前向传播：通过向模型传入x计算预测的y。\n",
    "    # 模块对象重载了__call__运算符，所以可以像函数那样调用它们。\n",
    "    # 这么做相当于向模块传入了一个张量，然后它返回了一个输出张量。\n",
    "    y_pred = model(x)\n",
    "    \n",
    "    # 计算并打印损失。我们传递包含y的预测值和真实值的张量，损失函数返回包含损失的张量。\n",
    "    loss = loss_fn(y_pred, y)\n",
    "    print(t, loss.item())\n",
    "    \n",
    "    # 反向传播之前清零梯度\n",
    "    model.zero_grad()\n",
    "\n",
    "    # 反向传播：计算模型的损失对所有可学习参数的导数（梯度）。\n",
    "    # 在内部，每个模块的参数存储在requires_grad=True的张量中，\n",
    "    # 因此这个调用将计算模型中所有可学习参数的梯度。\n",
    "    loss.backward()\n",
    "\n",
    "    # 使用梯度下降更新权重。\n",
    "    # 每个参数都是张量，所以我们可以像我们以前那样可以得到它的数值和梯度\n",
    "    with torch.no_grad():\n",
    "        for param in model.parameters():\n",
    "            param.data -= learning_rate * param.grad"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (Spyder)",
   "language": "python3",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": false,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {
    "height": "calc(100% - 180px)",
    "left": "10px",
    "top": "150px",
    "width": "227.797px"
   },
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
